package com.yysjyr.logisticssystem.settings.service.impl;

import com.yysjyr.logisticssystem.settings.entity.DicValue;
import com.yysjyr.logisticssystem.settings.mapper.DicValueMapper;
import com.yysjyr.logisticssystem.settings.service.DicValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DicValueServiceImpl implements DicValueService {

    @Autowired
    private DicValueMapper dicValueMapper;

    /**
     * @author: 吃货大人
     * @date: 2023/10/5
     * @time : 19:03
     * @param typeCode 字典类型编码
     * @return : 字典值的集合
     * @description: 根据字典类型编码查询字典值
     */
    @Override
    public List<DicValue> queryDicValuesByTypeCode(String typeCode){
        return dicValueMapper.selectDicValuesByTypeCode(typeCode);
    }

    /**
     * @author: 吃货大人
     * @date: 2023/10/5
     * @time : 19:04
     * @param typeCode 字典值类型
     * @return : 字典值对象
     * @description: 跟据字典值类型码查询并返回第一个
     */
    @Override
    public DicValue queryFirstDicValueByTypeCode(String typeCode) {
        return dicValueMapper.selectDicValuesByTypeCode(typeCode).get(0);
    }
}
